package com.tencent.qcloud.tuikit.tuichat.classicui.widget.message.viewholder;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.tencent.qcloud.tuicore.TUICore;
import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
import com.tencent.qcloud.tuikit.timcommon.classicui.widget.message.MessageContentHolder;
import com.tencent.qcloud.tuikit.timcommon.component.impl.GlideEngine;
import com.tencent.qcloud.tuikit.tuichat.R;
import com.tencent.qcloud.tuikit.tuichat.bean.message.CustomBusinessCardMessageBean;

public class CustomBusinessCardMessageHolder extends MessageContentHolder {
    private ImageView iv_head;
    private TextView tv_name;

    public CustomBusinessCardMessageHolder(View itemView) {
        super(itemView);
        iv_head = itemView.findViewById(R.id.iv_head);
        tv_name = itemView.findViewById(R.id.tv_name);
    }

    public static final String TAG = CustomBusinessCardMessageHolder.class.getSimpleName();

    @Override
    public int getVariableLayout() {
        return R.layout.custom_business_card_message_layout;
    }

    @Override
    public void layoutVariableViews(TUIMessageBean msg, int position) {
        String ID = "";
        String name = "";
        String head = "";
        String phone = "";
        if (msg instanceof CustomBusinessCardMessageBean) {
            ID = ((CustomBusinessCardMessageBean) msg).getUserID();
            head = ((CustomBusinessCardMessageBean) msg).getUserHead();
            name = ((CustomBusinessCardMessageBean) msg).getNickName();
        }

        GlideEngine.loadUserIcon(iv_head, head);
//        tv_name.setText(TUIChatService.getAppContext().getString(R.string.nick_name)+"："+name);
        tv_name.setText(name);
        msgContentFrame.setClickable(true);
        String finalUserId = ID;
        setMessageBubbleZeroPadding();
        msgContentFrame.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString("user_id", finalUserId);
                TUICore.startActivity("FriendHomeActivity", bundle);
            }
        });
    }
}
